//
//  PaperCollectionViewCell.m
//  ZYOnlineSchool
//
//  Created by 毕武侠 on 2017/3/9.
//  Copyright © 2017年 bwx. All rights reserved.
//

#import "PaperCollectionViewCell.h"
#import "PaperViewBuild.h"

@interface PaperCollectionViewCell ()

@property (nonatomic, strong) PaperBaseView *paperView;
@property (nonatomic, strong) PaperBaseModel *model;

@end

@implementation PaperCollectionViewCell
@dynamic model;

- (void)bindModel:(PaperBaseModel *)model {
    self.model = model;
//    _paperView =nil;
    [self.paperView bindModel:model];
}

- (PaperBaseView *)paperView {
    if (_paperView == nil) {
        _paperView = [PaperViewBuild createPaperViewWithIdentifier:self.model.identifier];
        _paperView.delegate = self;
        [self.contentView addSubview:_paperView];
    }
    return _paperView;
}

#pragma mark - PaperCollectionCellProtocol

// 上一层传给下一层
- (void)didActionWithData:(NSDictionary *)data {
    [self.paperView didActionWithData:data];
}

// 下一层传给上一层
- (void)responActionWithData:(NSDictionary *)data {
    
    if ([self.actionDelegate respondsToSelector:@selector(actionIndexPath:infoData:)]) {
        [self.actionDelegate actionIndexPath:self.indexPath infoData:data];
    }
}

@end
